package com.entidades.bdd;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;


@Entity
@Table(name = "Person")
@NamedQuery(name = "Person.findAll", query = "SELECT c FROM Person c")
public class Person extends BaseObject implements Serializable {
	/**
     * 
     */
	private static final long serialVersionUID = 456788L;
	private String firstName;
	private String lastName;
	@ManyToOne
	private Family family;
	
	@OneToMany(mappedBy = "person")
	private List<Job> jobList = new ArrayList<Job>();
	@Transient
	private String nonsenseField = "";
	
	public String getFirstName() {
		return firstName;
	}
	
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	// Leave the standard column name of the table
	public String getLastName() {
		return lastName;
	}
	
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	// @ManyToOne
	public Family getFamily() {
		return family;
	}
	
	public void setFamily(Family family) {
		this.family = family;
	}
	
	public List<Job> getJobList() {
		return this.jobList;
	}
	
	public void setJobList(List<Job> jobList) {
		this.jobList = jobList;
	}
	
	@Transient
	public String getNonsenseField() {
		return nonsenseField;
	}
	
	public void setNonsenseField(String nonsenseField) {
		this.nonsenseField = nonsenseField;
	}
	
	@Override
	public String toString() {
		return "Person [id=" + getId() + ", firstName=" + firstName + ", lastName=" + lastName + ", jobList="
		        + jobList.size() + "]";
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Person))
			return false;
		if (getId() != ((BaseObject) obj).getId())
			return false;
		return true;
	}
	
}
